package cn.itcast.controller;


import cn.itcast.SysLog;
import cn.itcast.service.SysLogService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/sysLog")
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(@RequestParam(name = "page",required = true,defaultValue = "1")int page,
                                @RequestParam(name = "size",required = true,defaultValue = "10")int size) throws Exception{
        ModelAndView mv = new ModelAndView();
       List<SysLog> sysLogs =  sysLogService.findAll(page,size);
        PageInfo pageInfo = new PageInfo(sysLogs);

       mv.addObject("pageInfo",pageInfo);
       mv.setViewName("syslog-list");

        return mv;
    }
}
